package com.infoDiffusion.front.action;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.apache.struts2.ServletActionContext;
import org.springframework.beans.factory.annotation.Autowired;

import com.infoDiffusion.bean.EarthquakeBean;
import com.infoDiffusion.bean.EmergencyBean;
import com.infoDiffusion.bean.HydroStatBean;
import com.infoDiffusion.bean.KnowledgeBean;
import com.infoDiffusion.bean.UserBean;
import com.infoDiffusion.bean.WeatherInfoBean;
import com.infoDiffusion.service.AllEventService;
import com.infoDiffusion.util.StringUtil;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;

public class NewsShowAction extends ActionSupport {
	@Autowired
	AllEventService allEventService;
	EarthquakeBean earthquakeBean;
	HydroStatBean hydroStatBean;
	WeatherInfoBean weatherInfoBean;
	EmergencyBean emergencyBean;
	KnowledgeBean knowledgeBean;
	UserBean bean;
	public HttpServletResponse response = ServletActionContext.getResponse();
	public HttpServletRequest request = ServletActionContext.getRequest();
	public HttpSession session = request.getSession();

	public String list() {
//		// 获取地震信息
//		List<EarthquakeBean> list1 = allEventService.liste(earthquakeBean);
//		ActionContext.getContext().put("list1", list1);
//		// 获取水文信息
//		List<HydroStatBean> list2 = allEventService.listh(hydroStatBean);
//		ActionContext.getContext().put("list2", list2);
//		// 获取气象信息
//		List<WeatherInfoBean> list3 = allEventService.listw(weatherInfoBean);
//		ActionContext.getContext().put("list3", list3);
//
//		return "list";
		WeatherInfoBean weather = allEventService.listweather(weatherInfoBean);
//		System.out.println(weather.size());
		
		ActionContext.getContext().put("weather", weather);
		return "listWeather";

	}

	public String listEarthquake() {
		List<EarthquakeBean> list1 = allEventService.liste(earthquakeBean);
		ActionContext.getContext().put("list1", list1);
		return "listEarthquake";
	}

	public String listHydroStat() {
		List<HydroStatBean> list2 = allEventService.listh(hydroStatBean);
		ActionContext.getContext().put("list2", list2);
		return "listHydroStat";
	}

	public String listWeatherInfo() {
		List<WeatherInfoBean> list3 = allEventService.listw(weatherInfoBean);
		ActionContext.getContext().put("list3", list3);
		return "listWeatherInfo";
	}
	
//	public String listWeather() {
//		
//	}
	
	public String listEmergencys(){
		List<EmergencyBean> list4 = allEventService.listem(emergencyBean);
		ActionContext.getContext().put("list4", list4);
		return "listEmergencys";
		
	}
	
	public String listEmergency(){
		int id = StringUtil.parstInt(request.getParameter("id"));
		EmergencyBean embean = allEventService.getByIdEmergency(id);
		ActionContext.getContext().put("embean", embean);
		return "listEmergency";
		
	}
	
	public String listKnowledge(){
		List<KnowledgeBean> list5 = allEventService.listk(knowledgeBean);
		ActionContext.getContext().put("list5", list5);
		return "listKnowledge";
	}
	
	public String listBasicKnow(){
		List<KnowledgeBean> listBasic = allEventService.listBasick(knowledgeBean);
		ActionContext.getContext().put("listBasic", listBasic);
		return "listBasic";
	}
	public String listLawKnow(){
		List<KnowledgeBean> listLaw = allEventService.listLawk(knowledgeBean);
		ActionContext.getContext().put("listLaw", listLaw);
		return "listLaw";
	}
	
	public String listFirstaidKnow(){
		List<KnowledgeBean> listFirstaid = allEventService.listFirstaidk(knowledgeBean);
		ActionContext.getContext().put("listFirstaid", listFirstaid);
		return "listFirstaid";
	}
	
	public String listPlanKnow(){
		List<KnowledgeBean> listPlan = allEventService.listPlank(knowledgeBean);
		ActionContext.getContext().put("listPlan", listPlan);
		return "listPlan";
	}
	public String listKnow(){
		int id = StringUtil.parstInt(request.getParameter("id"));
		KnowledgeBean kbean = allEventService.getById(id);
		ActionContext.getContext().put("kbean", kbean);
		return "listkbean";
	}
	
	public KnowledgeBean getKnowledgeBean() {
		return knowledgeBean;
	}

	public void setKnowledgeBean(KnowledgeBean knowledgeBean) {
		this.knowledgeBean = knowledgeBean;
	}

	public EmergencyBean getEmergencyBean() {
		return emergencyBean;
	}

	public void setEmergencyBean(EmergencyBean emergencyBean) {
		this.emergencyBean = emergencyBean;
	}

	public EarthquakeBean getEarthquakeBean() {
		return earthquakeBean;
	}

	public void setEarthquakeBean(EarthquakeBean earthquakeBean) {
		this.earthquakeBean = earthquakeBean;
	}

	public HydroStatBean getHydroStatBean() {
		return hydroStatBean;
	}

	public void setHydroStatBean(HydroStatBean hydroStatBean) {
		this.hydroStatBean = hydroStatBean;
	}

	public WeatherInfoBean getWeatherInfoBean() {
		return weatherInfoBean;
	}

	public void setWeatherInfoBean(WeatherInfoBean weatherInfoBean) {
		this.weatherInfoBean = weatherInfoBean;
	}

	public UserBean getBean() {
		return bean;
	}

	public void setBean(UserBean bean) {
		this.bean = bean;
	}

}
